import 'package:sainbainu/common/apis/content_api.dart';
import 'package:sainbainu/common/apis/message_api.dart';
import 'package:sainbainu/common/enums/message_type.dart';
import 'package:sainbainu/common/models/request/content_request.dart';
import 'package:sainbainu/common/models/request/pager_request.dart';
import 'package:sainbainu/common/models/request/resource_request.dart';
import 'package:sainbainu/common/models/response/content_response.dart';
import 'package:sainbainu/common/models/response/message_comment_response.dart';
import 'package:sainbainu/common/models/response/message_like_collect_response.dart';
import 'package:sainbainu/common/models/response/message_num_response.dart';

class MessageRepository {
  final MessageApi _messageApi;

  MessageRepository(this._messageApi);

  /// 赞和收藏列表
  Future<MessageLikeCollectListResponse> likeCollectionList(
    PagerRequest pagerRequest,
  ) async {
    var res = await _messageApi.likeCollectionList(pagerRequest.toJson());
    return MessageLikeCollectListResponse.fromJson(res);
  }

  /// 评论列表
  Future<MessageCommentListResponse> commentList(
    PagerRequest pagerRequest,
  ) async {
    var res = await _messageApi.commentList(pagerRequest.toJson());
    return MessageCommentListResponse.fromJson(res);
  }

  /// 获取未读消息数量
  Future<MessageNumResponse> getMessageNum() async {
    var res = await _messageApi.getMessageNum();
    return MessageNumResponse.fromJson(res['data']);
  }

  /// 清除消息数量
  Future<Map<String, dynamic>> clearMessageNum(
    MessageType msgType,
  ) async {
    var res = await _messageApi.clearMessageNum({
      'msgType': msgType.value,
    });
    return res;
  }
}
